$(document).ready(function (){
	$.ajax({
		url: "/airbnb/getHouseEquip.do",
	   	type: "POST",
	   	async: false,
	   	data: {"type":1},
	   	error: function (){
	   		alert("ajax请求失败")
	   	},
	   	success: function(json){
	   		for(var i = 0; i < json.length; i++){
	   			var html = "<div class='col-md-7 wxm-offpadding-bl'>";
	   			html += "<div class='checkbox checkboxstyle'>"
	   			html += "<label>";
	   			html += "<input type='checkbox' name='c1' style='width:20px;height: 20px;' value='"+json[i].value+"'>";
	   			html += "<span class='show-box'>√</span>";
	   			html += "<span class='wxm-checkboxtitle-step6'>"+json[i].text+"</span>";
	   			html += "</label></div></div>";
	   			$("#px1").append(html);
	   
	   		}
	   	}
	});
	$("#px1").append("<div class=\"col-md-7 wxm-offpadding-bl\" style=\"font-size:20px;color:#767676;\">安全设施</div>");
	$.ajax({
		url: "/airbnb/getHouseEquip.do",
	   	type: "POST",
	   	async: false,
	   	data: {"type":2},
	   	error: function (){
	   		alert("ajax请求失败")
	   	},
	   	success: function(json){
	   		for(var i = 0; i < json.length; i++){
	   			var html = "<div class='col-md-7 wxm-offpadding-bl'>";
	   			html += "<div class='checkbox checkboxstyle'>"
	   			html += "<label>";
	   			html += "<input type='checkbox' name='c2' style='width:20px;height: 20px;' value='"+json[i].value+"'>";
	   			html += "<span class='show-box'>√</span>";
	   			html += "<span class='wxm-checkboxtitle-step6'>"+json[i].text+"</span>";
	   			html += "</label></div></div>";
	   			$("#px1").append(html);
	   		}
	   	}
	});
	$("#px1").append("<div class='col-md-7' style='height:140px;'></div>");
	var html = "<div class='col-md-11 wxm-offpadding wxm-tablebottom-six' style='margin-top:540px;'>";
	html +="<div class='wxm-tablebottom-left'>";
	html +="<i class='fa fa-chevron-left' aria-hidden='true'></i>";
	html +="<a href='step5.html'>返回</a>";
	html +="</div>";
	html +="<div class='wxm-tablebottom-right' id='btn_next'>";
	html += "<span>下一步</span></div></div>";
	$("#px1").append(html);
	
	$("input[name='c1']").click(function (){
		var c = $(this).prop("checked");
		if(c){
			$(this).next(".show-box").show();
		}else{
			$(this).next(".show-box").hide();
		}
	})
	$("input[name='c2']").click(function (){
		var c = $(this).prop("checked");
		if(c){
			$(this).next(".show-box").show();
		}else{
			$(this).next(".show-box").hide();
		}
	})
	$(".show-box").click(function (){
		$(this).hide();
	});
	
	$("#btn_next").click(function (){
		var c1 = $("input[name='c1']:checked");
		var ca1 = new Array(); //js数组
		for(var i = 0; i < c1.length; i++){
			ca1.push(c1[i].value);
		}
		var c2 = $("input[name='c2']:checked");
		var ca2 = new Array(); //js数组
		for(var i = 0; i < c2.length; i++){
			ca2.push(c2[i].value);
		}
		
		$.ajax({
			url: "/airbnb/addHouseStep6.do",
			async: false,
		   	type: "POST",
		   	data: {"c1":ca1,"c2":ca2},
		   	error: function (){
		   		alert("ajax请求失败")
		   	},
		   	success: function(data){
		   		window.location.href="step7.html";
		   	}
		});
	});
});